<template>
  <div class="order-detail" v-if="order">
    <!-- 操作栏 -->
    <DetailAction :order="order" />
    <!-- 步骤条 组件xtx-steps.vue-->
    <XtxSteps :active="active">
      <XtxStepsItem title="提交订单" :desc="order.createTime" />
      <XtxStepsItem title="付款成功" :desc="order.payTime" />
      <XtxStepsItem title="商品发货" :desc="order.consignTime" />
      <XtxStepsItem title="确认收货" :desc="order.evaluationTime" />
      <XtxStepsItem title="订单完成" :desc="order.endTime" />
    </XtxSteps>
    <!-- 物流栏 -->
    <DetailLogistics :order="order" v-if="[3,4,5].includes(active)"></DetailLogistics>
    <!-- 订单商品信息 -->
    <OrderInfo :order="order"></OrderInfo>
  </div>
</template>
<script>
import { getOrderDetail } from '@/api/order'
import { ref } from 'vue'
import DetailAction from './components/detail-action'
import DetailLogistics from './components/detail-logistics'
import OrderInfo from './components/order-info'
import { useRoute } from 'vue-router'
export default {
  name: 'OrderDetail',
  components: { DetailAction, DetailLogistics, OrderInfo },
  setup() {
    const route = useRoute()
    const order = ref(null)
    const active = ref(1)
    getOrderDetail(route.params.orderId).then(data => {
      order.value = data.result
      active.value = data.result.orderState === 6 ? 1 : data.result.orderState
    })
    return { order, active }
  }
}
</script>
<style scoped lang="less">
.order-detail {
  min-height: 800px;
  background: #fff;
}
</style>